<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/sys/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>添加农事作业信息</title>
<%@ include file="/WEB-INF/sys/include/css.jsp"%>
<link href="${path}/res/js/webuploader/webuploader.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form" action="${path}/proRecord/save.json" method="post">
<div class="form">
	<div class="group">
		<div class="label">地块名称:</div>
		<div class="text" style="width:120px;">${plant.blockName }</div>
		<div class="label">种植作物:</div>
		<div class="text">${cropName }</div>
	</div>
	<div class="group">
		<div class="label">*作业环节:</div>
		<div class="item">
			<input type="text" id="linkName" name="linkName" />
			<input type="hidden" name="linkid" id="linkid" />
		</div>
		<div class="item" id="linkNameTip"></div>
	</div>
	<c:if test="${linkType==1 || linkType==2 || linkType==3 }">
	<div class="group">
		<div class="label">使用物资:</div>
		<div class="item">
			<input type="text" id="materialName" name="materialName" readonly="readonly" class="select_page" />
			<input type="hidden" name="materialid" id="materialid" />
		</div>
	</div>
	<div class="group">
		<div class="label">使用数量:</div>
		<div class="item"><input type="text" id="materialAmount" name="materialAmount" /></div>
		<div class="text" id="materialUnit"></div>
		<div class="item" id="materialAmountTip"></div>
	</div>
	</c:if>
	<div class="group">
		<div class="label">*作业人员:</div>
		<div class="item">
			<input type="text" id="workerName" name="workerName" />
			<input type="hidden" name="worker" id="worker" />
		</div>
		<div class="item" id="workerNameTip"></div>
	</div>
	<div class="group">
		<div class="label">*作业日期:</div>
		<div class="item"><input type="text" name="workdate" id="workdate" ltype="date" /></div>
		<div class="item" id="workdateTip"></div>
	</div>
	<div class="group">
		<div class="label">作业时间:</div>
		<div class="item">
			<input type="radio" id="worktime1" name="worktime" value="1" checked="checked" /><label for="worktime1" class="label">上午</label>
			<input type="radio" id="worktime2" name="worktime" value="2" /><label for="worktime2" class="label">下午</label>
		</div>
	</div>
	<div class="group">
		<div class="label">*备注:</div>
		<div class="item"><textarea id="remark" name="remark"></textarea></div>
	</div>
	<div class="group">
		<div class="label">作业图片:</div>
		<div class="item"><div id="myuploader" class="myuploader"></div></div>
	</div>
	<div class="buttons">
		<button class="highlight" id="submit1" type="button">确定</button>
		<button type="button" id="cancel1">取消</button>
		<input type="hidden" id="plantid" name="plantid" value="${plant.plantid}" />
		<input type="hidden" id="linkType" name="linkType" value="${linkType}" />
	</div>
</div>
</form>
<%@ include file="/WEB-INF/sys/include/script.jsp" %>
<script src="${path}/res/js/webuploader/webuploader.min.js" type="text/javascript"></script>
<script src="${path}/res/js/webuploader/myUploader.js" type="text/javascript"></script>
<script type="text/javascript">
var myuploader;
function getLayerData(){
	return {
		repertoryid: $("#materialid").val(),
    	linkType: '${linkType}',
    	blockType: '1',
    	parkid: '${plant.parkid}'
    };
}
$(function() {
	createSelect("linkName", "linkid", {
		url:'${path}/prolink/getProlinkData.json?cropid=${plant.cropid}&type=${linkType}'
	});
	
	if($("#materialName").length){
		$("#materialName").click(function(){
			layer.open({
				type : 2,
				title : "选择农资",
				maxmin : false,
				shadeClose : false, // 点击遮罩关闭层
				area : [ '800px', '550px' ],
				content : "${path}/proRecord/selectMaterial.do",
				btn: ['确定', '取消'],
				yes:function(index, layero){
					var data = $(layero).find('iframe')[0].contentWindow.getSelectedData();
					if(data){
						$("#materialName").val(data.materialName);
	            		$("#materialid").val(data.repertoryid);
	            		$("#materialUnit").html(data.unit);
					}else{
						$("#materialName").val("");
	            		$("#materialid").val("");
	            		$("#materialUnit").html("");
					}
					layer.close(index);
				},
				btn2: function(index){
					layer.close(index);
				}
			});
		});
	}
	
	createSelect("workerName", "worker", {
		valueField:'userid', textField: 'username',
		url:'${path}/userPark/getParkUserData.json?parkid=${plant.parkid}'
	});
	
	myuploader = $("#myuploader").myImgUploader({
		uploadDir: "prorecord_img",
		canEditDesc: true,
		webUploader:{
			fileNumLimit: 3
		}
	});
	
	$("#form").ligerForm({inputWidth: 300});
	
	verifyForm("form", {}, function(){
		$("#form").ajaxForm(function(data){
			UiUtil.isSuccess(data, "添加种植作业信息成功", function(){
				UiUtil.closeForm(true);
			});
		});
	});
	
	$("#submit1").click(function(){
		UiUtil.lockButton('submit1');
		if(!myuploader.isDone()){
			UiUtil.unlockButton('submit1');
			return;
		}
		$("#form").submit();
	});

	$("#cancel1").click(function(){
		UiUtil.closeForm();
	});
	
});
</script>
</body>
</html>